<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta name="copyright" content=
    "Copyright (c) IBM Corporation and others 2000, 2011. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
    <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type=
    "text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <title>
      Project using a source framework with restricted access
    </title>
    <script language="JavaScript" type="text/javascript" src=
    "PLUGINS_ROOT/org.eclipse.help/livehelp.js">

</script>
  </head>
  <body>
    <h1>
      Project using a source framework with restricted access
    </h1>
    <h3>
      Layout on file system
    </h3>
    <ul>

      <li>The Java source files for a product requires a source framework.
      </li>
      <li>"Product" and "Framework" are in separate directories which have
      their own source and output folders.
        <p>
          <img src="images/qs-WorkingWithExistingLayout60.png" alt=
          "Layout on file system" />
        </p>
      </li>
    </ul>
    <h3>
      Steps for defining corresponding projects
    </h3>

    <ol>
      <li>
        <p>
          Click <a class="command-link" href=
          'javascript:executeCommand("org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.jdt.ui.JavaPerspective)")'>
          <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt=
          "Opens the Java perspective" /> <strong>Window &gt; Open Perspective
          &gt; Other... &gt; Java</strong></a> to change to the Java
          perspective.
        </p>

      </li>
      <li>
        <p>
          Click <a class="command-link" href=
          'javascript:executeCommand("org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.ui.wizards.JavaProjectWizard)")'>
          <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt=
          "Opens the New Java Project wizard" /> <strong>File &gt; New &gt;
          Other... &gt; Java Project</strong></a> to open the <strong>New Java
          Project</strong> wizard.
        </p>

      </li>
      <li>
        <p>
          Type "Framework" in the <strong>Project name</strong> field.
        </p>
      </li>
      <li>
        <p>
          Deselect <strong>Use default location</strong>.
        </p>
        <p>
          Click <strong>Browse...</strong> and choose the
          <i><code>D:\Framework</code></i> directory.
        </p>

        <p>
          <img src="images/qs-WorkingWithExistingLayout61.png" alt=
          "New Java Project wizard" />
        </p>
        <p>
          Click <strong>Next</strong>.
        </p>
      </li>
      <li>

        <p>
          On the next page, verify that directory
          <i><code>JavaSourceFiles</code></i> has been automatically added as
          source folder.
        </p>
        <p>
          Expand it to preview your project source folder contents:
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout62.png" alt=
          "Java Project Source setup" />

        </p>
      </li>
      <li>Click <strong>Finish</strong>.
      </li>
      <li>
        <p>
          In Java perspective, type <strong>Ctrl+N</strong> to open
          <strong>New</strong> wizards dialog.
        </p>

        <p>
          Select <strong>Java project</strong> in the list of wizards and click
          <strong>Next</strong>.
        </p>
      </li>
      <li>
        <p>
          On the next page, type "Product" in the <strong>Project name</strong>

          field.
        </p>
      </li>
      <li>
        <p>
          Deselect <strong>Use default location</strong>.
        </p>

        <p>
          Click <strong>Browse...</strong> and choose the
          <i><code>D:\Product</code></i> directory.
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout63.png" alt=
          "New Java Project wizard" />
        </p>

      </li>
      <li>
        <p>
          Click <strong>Next</strong>.
        </p>
      </li>
      <li>
        <p>

          On the next page, verify that directory
          <i><code>JavaSourceFiles</code></i> has been automatically added as
          source folder.
        </p>
        <p>
          Expand it to preview your project source folder contents:
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout64.png" alt=
          "Java Project Source setup" />
        </p>

      </li>
      <li>
        <p>
          Select <strong>Projects</strong> tab.
        </p>
        <p>
          Click <strong>Add...</strong>to add a dependency to source framework
          project...
        </p>

        <p>
          <img src="images/qs-WorkingWithExistingLayout65.png" alt=
          "Java Project Required Projects setup" />
        </p>
      </li>
      <li>
        <p>
          In <strong>Required Project Selection</strong>, check "Framework".
        </p>

        <p>
          <img src="images/qs-WorkingWithExistingLayout66.png" alt=
          "Required Project Selection dialog" />
        </p>
      </li>
      <li>
        <p>
          Click <strong>OK</strong> to validate and close dialog.
        </p>

      </li>
      <li>
        <p>
          Now, let's put access rules on source framework content to authorize,
          discourage or forbid access to "Framework" source folders, package
          and classes...
        </p>
        <p>
          In <strong>Projects</strong> tab, select "Access rules" of
          "Framework" depending project.
        </p>

        <p>
          Click <strong>Edit...</strong>.
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout67.png" alt=
          "Edit Required Project Access Rules" />
        </p>
      </li>
      <li>

        <p>
          In <strong>Type Access Rules</strong>, click <strong>Add...</strong>.
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout68.png" alt=
          "Type Access Rules dialog" />
        </p>
      </li>

      <li>
        <p>
          In <strong>Add Access Rule</strong>, select "Forbidden" for
          <strong>Resolution</strong>.
        </p>
        <p>
          Type "**/forbidden/**" in <strong>Rule Pattern</strong> field.
        </p>

        <p>
          <img src="images/qs-WorkingWithExistingLayout69.png" alt=
          "Add Access Rule dialog" />
        </p>
      </li>
      <li>
        <p>
          Click <strong>OK</strong> to validate access rule and close dialog.
        </p>

      </li>
      <li>
        <p>
          Add another access rule:
        </p>
        <p>
          <strong>Resolution</strong>: "Discouraged" and <strong>Rule
          Pattern</strong>: "**/internal/**".
        </p>

      </li>
      <li>
        <p>
          Your access rules now look as follows:
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout6a.png" alt=
          "Type Access Rules final result" />
        </p>
      </li>

      <li>
        <p>
          Click <strong>OK</strong> to validate these new rules and close
          dialog.
        </p>
      </li>
      <li>
        <p>
          Dependent project has now 2 access rules set.
        </p>

        <p>
          <img src="images/qs-WorkingWithExistingLayout6b.png" alt=
          "Java Project Required Projects final setup" />
        </p>
      </li>
      <li>
        <p>
          Click <strong>Finish</strong>.
        </p>

      </li>
      <li>
        <p>
          You now have a Java project which contains the source of "Product"
          and which is using the source of "Framework".
        </p>
        <p>
          Some packages of the project "Framework" are restricted and if you
          try to import them, compiler displays either warnings or errors
          depending on your restriction level:
        </p>
        <p>
          <img src="images/qs-WorkingWithExistingLayout6c.png" alt=
          "Created Java projects in Workspace" />

        </p>
      </li>
    </ol>
    <p class="nav_footer" id="nav_footer">
      Next Section: <a href="qs-with-j2se50.htm">Eclipse and J2SE 5.0</a>
    </p>

    <h3 class="related">Related concepts</h3>
      <a href="../concepts/concept-java-project.htm">Java projects</a>

    <h3 class="related">Related references</h3>
      <a href="../reference/ref-wizard-java-project.htm">New Java Project
      Wizard</a><br />
      <a href="../reference/views/ref-view-package-explorer.htm">Package
      Explorer View</a>
  </body>
</html>
